package A1_哈希表;

import java.util.HashMap;
import java.util.Iterator;

public class LC_001两数之和 {
    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer,Integer> map=new HashMap<>();
        int s=0;
        for(int i=0;i<nums.length;i++){
            s=target-nums[i];
            if(map.containsKey(s))
                return new int[]{map.get(s), i};
            map.put(nums[i],i);
        }
        return new int[0];
    }
}
